package com.atguigu.gulimall.product.web.controller;

import com.atguigu.gulimall.product.service.SkuInfoService;
import com.atguigu.gulimall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class itemController {


    @Autowired
    SkuInfoService skuInfoService;


    /**
     * 跳转到商品的详情页
     * @param skuId 详情页商品的sku编号
     * @return
     */
    @GetMapping("/{skuId}/item.html")
    public String toItem(@PathVariable("skuId") long skuId, Model model){
        SkuItemVo skuItemVo=skuInfoService.item(skuId);
        model.addAttribute("item",skuItemVo);
        return "item";
    }

}
